package net.ikenna.yadet.core.data;

import org.apache.log4j.*;

public class ListDataLogger implements DataLogger {

    public void log(String description, RowSet data, Logger logger) {
        logger.info(description);
        for (Row row : data.getRows()){
            logColumnHeadingAndValues(row, logger);
        }
    }

    private void logColumnHeadingAndValues(Row row, Logger logger) {
        StringBuilder keyValuePairs = new StringBuilder();
        for (Object key : row.getColumns()){
            keyValuePairs.append(String.format("%s: %s, ", key , row.getColumnValue((String) key)));
        }
        logger.info("[Row] " + keyValuePairs.toString());
    }
}
